<?php
defined('_JEXEC') or die('Restricted access');
global $mainframe;
$document =& JFactory::getDocument();
//jimport('joomla.html.pane');
$editor = & JFactory :: getEditor();

$document->addStyleSheet('components/com_wrecruit/css/other_employers.css');
$document->addScript ('components/com_wrecruit/js/other_employers.js');
$document->addScript( 'components/com_wrecruit/js/emppopup.js' );
$document->addStyleSheet('components/com_wrecruit/css/emppopup.css');
$model = $this->getModel('wrecruit', 'WRecruitModel');
?>
<style type="text/css">

</style>
<script language="Javascript">
function removeMessage(mid) {
	var answer = confirm("Are you sure to delete?")
	if (answer){
		window.location = "/index.php?option=com_wrecruit&c=wrecruit&task=removeOneMessage&box=candidate_sent&sort=DESC&page=1&Itemid=<?php echo $this->Itemid; ?>&mid="+mid;
	}
}
</script>

<?php if ($this->config['offline'] == '1'){ ?>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
	<tr>
		<td valign="top" class="<?php echo $this->theme['title']; ?>"><?php echo $this->config['title']; ?>
		</td>
	</tr>
	<tr>
		<td height="25"></td>
	</tr>
	<tr>
		<td class="wrecruitmsg"><?php echo $this->config['offline_text']; ?>
		</td>
	</tr>
</table>
<?php }
else{
	if (isset($this->userrole->rolefor)){
		if ($this->userrole->rolefor == 1) // employer
		$allowed = true;
		else
		$allowed = false;
	}
	else { if ($this->config['visitorview_emp_conrolpanel'] == 1) $allowed = true; else $allowed = false; } // user not logined
	if ($allowed == true) {
		?>
<div class="box-list-job">
	<div class="job-seeker-panel">
	<?php include 'left_panel.php';?>
	</div>
	<div class="job-seeker-right">
		<form name="frm_msg" id="frm_emp" method="post"	action="index.php">
			<div class="message-list">
				<div class="box">
					<a href="<?php echo JURI::base()."index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=messagelist&box=candidate_sent&sort=DESC&page=1&Itemid=". $this->Itemid; ?>">
						<span>Inbox</span>
					</a>
					<a href="<?php echo JURI::base()."index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=messagelist&box=employer_sent&sort=DESC&page=1&Itemid=". $this->Itemid; ?>">
						<span>Sent</span>
					</a>
				</div>
				<div class="menu">
					<span style="float:right" onclick="removeMessage(frm_msg.mid.value)">Delete</span>
					<span class="replymessage" id="replymessage" >Reply</span>
					<span class="replymessage" id="forwardmessage">Forward</span>
				</div>
				<?php  foreach ($this->message as $item) {?>
				<input type="hidden" name="mid" value="<?php echo $item->id;?>" />
				<div class="item">
					<div class="sub-item sub_item_detail">
						<span style="margin:10px;"><strong><?php echo $item->subject; ?></strong></span>
						<div>
							<div class="pic" style="margin:10px;">
								<img alt="photo" src="components/com_wrecruit/images/candidate_pic.png" />
							</div>
							<div>
								<span><?php echo $item->name; ?></span><br/>
								<span>To:&nbsp;<?php echo $item->empname; ?></span><br/>
								<span>Date:&nbsp;<?php echo date('M d',strtotime($item->created)); ?> </span>
							</div>
						</div>
					</div>
				</div>
				<div style="margin:10px;padding:15px; border:1px solid #ccc;">
					<span>
						<?php echo $item->message;?>
					</span>
				</div>
					<input type="hidden" id="cname" name="<?php echo $item->name;?>" />
					<input type="hidden" id="email" name="<?php echo $item->email;?>" /> 
					<input type="hidden" id="cid" name="<?php echo $item->jobseekerid;?>" />
					<input type="hidden" id="empid" name="<?php echo $item->employerid;?>" />
					<input type="hidden" id="subject" name="<?php echo $item->subject;?>" />	
				<?php }?>
				<div class="menu">
					<span style="float:right" onclick="removeMessage(frm_msg.mid.value)">Delete</span>
					<span class="replymessage" id="replymessage2" >Reply</span>
					<span class="replymessage" id="forwardmessage2">Forward</span>
				</div>
			</div>	
		</form>
	</div>	
</div>
<?php } else{ // not allowed job posting
		echo JText::_('EA_YOU_ARE_NOT_ALLOWED_TO_VIEW');
	}
}//ol
?>
<div id="popupContainer" class="hidden" style="text-align:left;">
     fdfddfd
</div>
<div id="overlayEffect">
</div>
<div width="100%">
<?php
if($this->config['fr_cr_txsh']) {
	echo
	'<table width="100%" style="table-layout:fixed;">
		<tr><td height="15"></td></tr>
		<tr><td style="vertical-align:top;" align="center">'.$this->config['fr_cr_txa'].$this->config['fr_cr_txb'].'</td></tr>
	</table>';
}
?>
</div>
